import type {
  AddressItem,
  Logistics,
  OrderDetail,
  OrderPre
} from '@/types/order'
import { request } from '@/utils/request'

// 获取预支付的收货人地址详情 订单-查询收货地址列表
/**
 * 订单-查询收货地址列表
 * @returns Promise对象
 */
export const getAddressListAPI = () =>
  request<AddressItem[]>('/patient/order/address')

// 查询药品订单预支付信息
export const getMedicalOrderPreAPI = (params: { prescriptionId: string }) =>
  request<OrderPre>('/patient/medicine/order/pre', 'GET', params)

/**
 * 药品订单-根据处方下药品订单
 * @param data 请求参数
 * @returns Promise对象
 */
export const createMedicineOrderAPI = (data: {
  id: string
  couponId?: string
  addressId: string
}) => request<{ id: string }>('/patient/medicine/order', 'POST', data)

/**
 * 药品订单-查询订单详情信息
 * @param id orderId
 * @returns Promise对象
 */
export const getMedicalOrderDetailAPI = (id: string) =>
  request<OrderDetail>(`/patient/medicine/order/detail/${id}`)

/**
 * 订单-查询物流信息
 * @param id 订单id
 * @returns Promise对象
 */
export const getMedicalLogisticsInfoAPI = (id: string) =>
  request<Logistics>(`/patient/order/${id}/logistics`)
